<?php
/**
 * [PHPFOX_HEADER]
 */

defined('PHPFOX') or exit('NO DICE!');

class TnSkype_Service_tnskype extends Phpfox_Service 
{

	public function getSkype($user_id)
	{

		$skypeAccount = $this->database()->select("*")
			->from(Phpfox::getT('skype_user'), 'su')
			->where('su.user_id = ' . (int) $user_id)
			->execute('getSlaveRow');
		
		return $skypeAccount;
	}

	public function addSkype($user_id,$skype_account,$active)
	{
		$skypeAccount = $this->database()->select("*")
			->from(Phpfox::getT('skype_user'), 'su')
			->where('su.user_id = ' . (int) $user_id)
			->execute('getSlaveRow');
		if(count($skypeAccount) <= 0){
			$aInsert = array(
								'user_id' =>$user_id,
								'skype_account' => $skype_account,
								'active ' =>(int)$active,
								 );
			$this->database()->insert(Phpfox::getT('skype_user'), $aInsert);
		}
		else{
			$this->database()->update(Phpfox::getT('skype_user'), array('skype_account' => $skype_account, 'active ' =>(int)$active ),'skype_user_id = '.$skypeAccount['skype_user_id'] );

		}
	}

		
}

?>